/* GUI CONVERTED from glabrp2.i (converter v1.75) Thu Jan 25 08:09:28 2001 */
/* glabrp2.i - SUBROUTINE FOR GENERAL LEDGER ACCOUNT BALANCE REPORT        */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                     */
/* All rights reserved worldwide.  This is an unpublished work.            */
/*F0PN*/ /*V8:ConvertMode=Report                                           */
/*               CALCULATES AMOUNTS FOR SUMMARIZED OPTIONS                 */
/* REVISION: 7.0      LAST MODIFIED: 01/29/92   by: jms  *F107*            */
/* REVISION: 8.5      LAST MODIFIED: 03/19/98   by: *J240* Kawal Batra     */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00   by: *N0L1* Mark Brown      */
/* REVISION: 9.1      LAST MODIFIED: 08/04/00   BY: *N0VY* Mudit Mehta     */
/***************************************************************************/
/*!
This include file calculates the beginning balance and period activity for
   the account balance report when "summarize sub-account" and/or "summarize
   cost centers" options are selected.
*/
/***************************************************************************/
/*J240********** GROUPED MULTIPLE FIELD ASSIGNMENTS INTO ONE
                 FOR PERFORMANCE AND FOR SMALLER r-CODE *******J240*/
/* REVISION: EB2 SP3  LAST MODIFIED: 11/27/03 BY: Kaine Zhang   *hk-s-023* */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

/*N0VY*/ {cxcustom.i "GLABRP2.I"}
      /* READ ACCOUNT MASTER RECORD */
/*J240** find ac_mstr where ac_code = asc_mstr.asc_acc no-lock. **/
/*J240*/ for first ac_mstr fields (ac_code ac_active ac_type ac_curr ac_desc)
/*J240*/    where ac_code = asc_mstr.asc_acc no-lock: end.

      /* CALCULATE BEGINNING BALANCE */
      if lookup(ac_type, "A,L") = 0 then do:
/*hk-s-023*         {glacbal1.i &acc=asc_acc &sub=asc_sub &cc=asc_cc  */
/*hk-s-023*/        {xxglacbal1.i &acc=asc_acc &sub=asc_sub &cc=asc_cc
           &begdt=yr_beg &enddt=begdtxx &balance=amt
        &yrend=yr_end &rptcurr=rpt_curr &accurr=ac_curr}
      end.
      else do:
/*N0VY*/ {&GLABRP2-I-TAG1}
/*hk-s-023*         {glacbal1.i &acc=asc_acc &sub=asc_sub &cc=asc_cc  */
/*hk-s-023*/        {xxglacbal1.i &acc=asc_acc &sub=asc_sub &cc=asc_cc
        &begdt=low_date &enddt=begdtxx &balance=amt
        &yrend=yr_end &rptcurr=rpt_curr &accurr=ac_curr}
/*N0VY*/ {&GLABRP2-I-TAG2}
      end.
      assign beg_bal = beg_bal + amt.

      /* CALCULATE PERIOD ACTIVITY */
      for each cal where cal.glc_year = yr and cal.glc_per >= per and
                 cal.glc_per <= per1 no-lock:

         /* LOOK UP TRANSACTIONS */
         assign begdt1 = begdt.
         if begdt1 < cal.glc_start then assign begdt1 = cal.glc_start.
         assign enddt1 = enddt.
         if enddt1 > cal.glc_end then assign enddt1 = cal.glc_end.
         assign knt = 0.

/*hk-s-023*         {glacbal1.i &acc=asc_acc &sub=asc_sub &cc=asc_cc  */
/*hk-s-023*/        {xxglacbal1.i &acc=asc_acc &sub=asc_sub &cc=asc_cc
        &begdt=begdt1 &enddt=enddt1 &balance=amt
        &yrend=yr_end &rptcurr=rpt_curr &accurr=ac_curr}

         assign
         peramt[cal.glc_per] = peramt[cal.glc_per] + amt
         xknt[cal.glc_per] = xknt[cal.glc_per] + knt.
      end.
